Python Algorithmic Trading Cookbook by Pushpak Dagade
Author:Pushpak Dagade [Pushpak Dagade]
Language: eng
Format: epub
Tags: COM027000 - COMPUTERS / Desktop Applications / Personal Finance Applications, COM062000 - COMPUTERS / Data Modeling and Design, COM018000 - COMPUTERS / Data Processing
Publisher: Packt Publishing
Published: 2020-08-28T13:12:37+00:00
(The attributes passed to the place_order() method are broker-agnostic constants, imported earlier from the pyalgotrading.constants module.)
On placing the order in step 2, you get an order ID from the broker, which you assign to a new attribute, order1_id. The order1_id object is a string. If the order placement is not successful for some reason, you may not get an order ID. Observe that the price and trigger_price parameters are passed a value of ltp+1. This means the order is placed above the market price, which is a necessary condition for placing buy stoploss-limit orders. The stoploss parameter is specified as 2. This means the stoploss order would be placed at the price that is 2 price units lower than the execution price of the initial order. Similarly, the target parameter is specified as 2. This means the target order would be placed at the price that is 2 price units higher than the execution price of the Initial Order.
In step 3, you fetch the status of the placed order using the get_order_status() method of the broker_connection object. You pass order1_id as a parameter to the get_order_status() method. You get the order status as 'TRIGGER PENDING', a string. You can use order1_id to fetch the status of the placed order at any later point of time as well. In step 4, you fetch the order status again, and if the order is completed, you get the order status as 'COMPLETE'. Immediately after this, the target and stoploss orders are placed, at the prices mentioned earlier. The target order executes as a regular limit order. The stoploss order executes as a regular stoploss-limit order. When one of them gets executed and reaches the 'COMPLETE' state, the other order is automatically canceled by the broker, so it moves to the 'CANCELLED' state. Recall, both target and stoploss orders are on opposite sides of the initial order, so both target and stoploss orders cannot execute at the same time.
In step 3, if you see the status as 'COMPLETE' instead of 'TRIGGER PENDING', this could be due to high volatility. If you want the order to stay in the 'OPEN' state for a while, try placing the order further away from the market price. The following are references to more details on the execution of the initial order, target order, and stoploss order:
Initial order: Refer to the Placing a regular stoploss-limit order recipe in the previous chapter.
Target order: Refer to the Placing a regular limit order recipe in the previous chapter.
Stoploss order: Refer to the Placing a regular stoploss-limit order recipe in the previous chapter.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Ada | Ajax |
Assembly Language Programming | Borland Delphi |
C & C++ | C# |
CSS | Compiler Design |
Compilers | DHTML |
Debugging | Delphi |
Fortran | Java |
Lisp | Perl |
Prolog | Python |
RPG | Ruby |
Swift | Visual Basic |
XHTML | XML |
XSL |
Hello! Python by Anthony Briggs(9911)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9794)
The Mikado Method by Ola Ellnestam Daniel Brolund(9775)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8292)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(7775)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7758)
Grails in Action by Glen Smith Peter Ledbrook(7693)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7557)
Windows APT Warfare by Sheng-Hao Ma(6785)
Layered Design for Ruby on Rails Applications by Vladimir Dementyev(6511)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6409)
Blueprints Visual Scripting for Unreal Engine 5 - Third Edition by Marcos Romero & Brenden Sewell(6378)
Kotlin in Action by Dmitry Jemerov(5061)
Hands-On Full-Stack Web Development with GraphQL and React by Sebastian Grebe(4315)
Functional Programming in JavaScript by Mantyla Dan(4037)
Solidity Programming Essentials by Ritesh Modi(3976)
WordPress Plugin Development Cookbook by Yannick Lefebvre(3762)
Unity 3D Game Development by Anthony Davis & Travis Baptiste & Russell Craig & Ryan Stunkel(3705)
The Ultimate iOS Interview Playbook by Avi Tsadok(3680)
